home *** CD-ROM | disk | FTP | other *** search
- Path: keats.ugrad.cs.ubc.ca!not-for-mail
- From: c2a192@ugrad.cs.ubc.ca (Kazimir Kylheku)
- Newsgroups: comp.lang.ada,comp.lang.c++,comp.lang.c,comp.lang.modula3,comp.lang.modula2,comp.lang.eiffel
- Subject: Re: Hungarian notation
- Date: 21 Jan 1996 09:34:07 -0800
- Organization: Computer Science, University of B.C., Vancouver, B.C., Canada
- Message-ID: <4dttefINNo29@keats.ugrad.cs.ubc.ca>
- References: <30C40F77.53B5@swsbbs.com> <4bd <4cc2b2$11jq@navajo.gate.net> <4cud8f$gup@news.netvision.net.il>
- NNTP-Posting-Host: keats.ugrad.cs.ubc.ca
-
- In article <4cud8f$gup@news.netvision.net.il>,
- Uri Simchoni <simchoni@netvision.net.il> wrote:
- >In article <4cc2b2$11jq@navajo.gate.net>, feathers@gate.net says...
- >>Where I work, all the truly portable code is written in terms of
- >>typedefs. We alter the typedefs in an include file to alter data
- >>sizes and performance characeristic, and our variant of Hungarian
- >>uses these type names.
- >
- >I'm trying to get used to the idea...
- >
- >What if you have a variable which contains the delay between two
- >operations in milliseconds. Do you make up a new type, say
- >
- >typedef unsigned MSEC
- >
- >and declare:
- >
- >MSEC cmsecDelayBetweenCharacters; ?
- >
- >Where do you put all those typedefs? in the beginning of the .c file,
- >right before the declaration of in a separate .h file?
- >
- >Thanks for your response,
- >Uri
-
- I say, don't bother. I avoid typedefs like the plague, even for structures. I
- much rather write the longer form.
-
- void myfunction(struct whatever *x);
-
- Using excessive typedefs will just occlude your code. What is the point of
- having a separate type for MSEC? Later, when someone sees a declaration of a
- variable of type MSEC, he will have to go hunting and pecking for the
- definition of MSEC. It _obviously_ stands for milliseconds, but what the hell
- is it?
-
- I once help a guy debug his program which was for an operating systems course.
- He did things like typedef char * MESSAGE. Now, his code looked as readable as
- a large print book from the community library, sure. But debugging it was
- awkward. I had no idea what the heck a MESSAGE was, at first glance. A
- structure? A string? An integer "cookie"? In fact, the bugs in the program were
- related to the severe levels of abstraction used in the naming of types and
- variables.
-
- The prof himself called it "anal retentive" and encouraged the man to ease up a
- little bit. :)
-
- All this talk about Hungarian Notation and whatnot is just silliness. To me,
- all identifiers declared in this notation look the same, and can be easily
- confused. When choosing a notation, plan ahead for the time when you are up at
- three in the morning with blood-shot eyes trying to find some bug! Think how
- these silly prefixes and suffixes will start to float in front of your eyes,
- and mingle like cream and coffee...
- --
-
-